Source Code Viewer - Example 14 - ViewPrimeMinisterListAction

package name.matthewgreet.example14.action;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.ActionContext;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import name.matthewgreet.example14.dto.PrimeMinisterDTO;
import name.matthewgreet.example14.util.PrimeMinisterCompositeCache;
import name.matthewgreet.example14.view.LocaleSelectBoxDisplay;
import name.matthewgreet.example14.view.PrimeMinisterDisplay;
import name.matthewgreet.strutscommons.action.AbstractViewListActionSupport;
import name.matthewgreet.strutscommons.util.ListCache;
import name.matthewgreet.strutscommons.util.NA;

/**
 * Displays list of UK Prime Ministers.  
 */
@InterceptorRef("ViewStack")
@Results({
	@Result(name=ActionSupport.SUCCESS, location="/pages/PrimeMinisterList.jsp")
})
public class ViewPrimeMinisterListAction extends AbstractViewListActionSupport<NA,Integer,PrimeMinisterDTO,PrimeMinisterDisplay> {
	private static final long serialVersionUID = -7979376337555804889L;
	
    private Logger LOG = LogManager.getLogger(ViewPrimeMinisterListAction.class);
    
    
	private LocaleSelectBoxDisplay localeSelectBoxDisplay;
	

	
    @Override
	protected PrimeMinisterDisplay formatRecord(NA selectedMaster,PrimeMinisterDTO record) {
		return new PrimeMinisterDisplay(record);
	}

	@Override
	protected ListCache<NA,Integer,PrimeMinisterDTO> getListCache() {
		return PrimeMinisterCompositeCache.getInstance(getBrowserTabSession()).getMasterListCache();
	}


	@Override
	protected ListCache<?,?,NA> getMasterListCache() {
		return null;
	}


	@Override
	protected ViewListConfig getViewListConfig() {
		return ViewListConfig.makeNonPagedListConfig();
	}

    protected String getViewResponse(NA selectedMaster, PrimeMinisterDTO selectedItem) throws Exception {
	    localeSelectBoxDisplay = new LocaleSelectBoxDisplay();
	    localeSelectBoxDisplay.setSelectedValue(ActionContext.getContext().getLocale().getLanguage() + "_" + ActionContext.getContext().getLocale().getCountry());
	    
		return SUCCESS;
    }
    
	@Actions({
    	@Action("/"),
    	@Action("/ViewPrimeMinisterList")
    })
    @Override
    public String execute() throws Exception {
		return super.execute();
    }

	public LocaleSelectBoxDisplay getLocaleSelectBoxDisplay() {
		return localeSelectBoxDisplay;
	}

	@Override
	public Logger getLogger() {
		return LOG;
	}

}